package com.shuoyue.ycgk.ui.recruitment.newsinfo;

import com.shuoyue.ycgk.base.BasePresenter;
import com.shuoyue.ycgk.base.BaseResult;
import com.shuoyue.ycgk.base.BaseView;
import com.shuoyue.ycgk.base.ListWithPage;
import com.shuoyue.ycgk.entity.JobInfo;
import com.shuoyue.ycgk.entity.RecruitmentItem;
import com.shuoyue.ycgk.net.RetrofitClient;
import com.shuoyue.ycgk.net.base.ApiSubscriber;
import com.shuoyue.ycgk.net.gsondefaultadapter.Optional;

import io.reactivex.Observable;

public interface RecurimentInfoContract {
    interface View extends BaseView {
        void setRecurimentInfo(RecruitmentItem recurimentInfo);


    }

    class Presenter extends BasePresenter<View> {
        Model model = new Model();

        public void getRecurimentInfo(int id) {
            apply(model.getRecurimentInfo(id))
                    .subscribe(new ApiSubscriber<Optional<RecruitmentItem>>(mView, this) {
                        @Override
                        public void onNext(Optional<RecruitmentItem> recruitmentItemOptional) {
                            super.onNext(recruitmentItemOptional);
                            mView.setRecurimentInfo(recruitmentItemOptional.getIncludeNull());
                        }
                    });
        }


    }

    class Model {
        public Observable<BaseResult<RecruitmentItem>> getRecurimentInfo(int id) {
            return RetrofitClient.getInstance().getApi().getRecurimentInfo(id);
        }


    }
}
